home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Libris Britannia 4
/
science library(b).zip
/
science library(b)
/
DJGPP
/
DJSRC111.ZIP
/
go32
/
stamp.c
< prev
next >
Wrap
C/C++ Source or Header
|
1993-06-26
|
1KB
|
58 lines
/* This is file STAMP.C */
/*
** Copyright (C) 1993 DJ Delorie, 24 Kirsten Ave, Rochester NH 03867-2954
**
** This file is distributed under the terms listed in the document
** "copying.dj", available from DJ Delorie at the address above.
** A copy of "copying.dj" should accompany this file; if not, a copy
** should be available from where this file was obtained. This file
** may not be distributed without a verbatim copy of "copying.dj".
**
** This file is distributed WITHOUT ANY WARRANTY; without even the implied
** warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
#include <stdio.h>
#include <time.h>
char key[] = "TIMETIME";
char *stamp;
main(int argc, char **argv)
{
FILE *f;
int key_p = 0, ch;
long t;
time(&t);
stamp = ctime(&t);
stamp[strlen(stamp)-1] = 0;
if (argc != 2)
{
fprintf(stderr, "Usage: stamp {program}\n");
exit(1);
}
f = fopen(argv[1], "r+b");
while ((ch = fgetc(f)) != EOF)
{
if (ch == key[key_p])
{
key_p++;
if (key[key_p] == 0)
{
long pos = ftell(f);
fseek(f, pos, 0);
fwrite(stamp, 1, strlen(stamp), f);
fseek(f, pos, 0);
}
}
else
key_p = 0;
}
fclose(f);
}